/*
 * @Description: 减签
 */
import { useBaseInfoWithOut } from '@/store/modules/base-info';
import globalData from '@/plugins/data';
import {fireEvent, getCollEventParams} from "@/handles/common/sdk";
import {useBaseInfoStore} from "@/store/modules/base-info";

const useBaseInfo = useBaseInfoWithOut();
export function removeNode() {
    const {
        affair: { activityId: wfActivityId },
        currentUser: { id },
        workflow: { itemId: wfItemId, processId, caseId },
        summary:{canDeleteNode},
        template
    } = useBaseInfo.baseInfo.businessData;
    const {workflowId}=template||{}
    deleteNode(
        wfItemId,
        processId,
        wfActivityId,
        id,
        caseId,
        window.refreshWorkflow,
        globalData.summaryId,
        globalData.affairId,
        workflowId?'true':'false',
        'true',
        'collaboration',
        canDeleteNode === false ? 'false':'true'
    );
}

export default function () {
    return new Promise(async (resolve) => {
        const businessData = useBaseInfoStore().baseInfo?.businessData || {};
        const eventParams = getCollEventParams(businessData, globalData);
        let eventResult = await fireEvent("RemoveNode", eventParams);
        if (!eventResult) {
            return resolve();
        }
        removeNode.call(this);
        resolve();
    });
}
